// HTalkModifyInfo.cpp : implementation file
//

#include "stdafx.h"
#include "HTalk.h"
#include "HTalkModifyInfo.h"
#include "afxdialogex.h"

extern Client client;
// CHTalkModifyInfo dialog

IMPLEMENT_DYNAMIC(CHTalkModifyInfo, CDialog)

CHTalkModifyInfo::CHTalkModifyInfo(CWnd* pParent /*=NULL*/)
	: CDialog(CHTalkModifyInfo::IDD, pParent)
{
}

CHTalkModifyInfo::~CHTalkModifyInfo()
{
	delete this;
}

void CHTalkModifyInfo::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BOOL CHTalkModifyInfo::OnInitDialog()
{
	this->SetDlgItemInt(IDC_ID, client.GetUserInfo()->iId, false);
	this->SetDlgItemText(IDC_NICKNAME, client.GetUserInfo()->szUserName);
	this->CheckDlgButton(IDC_RADIO_MALE, BST_CHECKED);
	((CStatic*)this->GetDlgItem(IDC_IMAGE))->SetBitmap(::LoadBitmap(
		::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP0 + client.GetUserInfo()->iImgID)));
	return TRUE;
}

BEGIN_MESSAGE_MAP(CHTalkModifyInfo, CDialog)
	ON_BN_CLICKED(IDOK, &CHTalkModifyInfo::OnBnClickedOk)
END_MESSAGE_MAP()


// CHTalkModifyInfo message handlers


void CHTalkModifyInfo::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	USER_INFO user;
	memcpy(&user, client.GetUserInfo(), sizeof(USER_INFO));
	char name[16];
	this->GetDlgItemText(IDC_NICKNAME, name, 16);
	sprintf(user.szUserName, "%s", name);
	client.ModifyInfo(&user);
	CDialog::OnOK();
}
